class Solution
{
public:
    string alphabetBoardPath(string target)
    {
        string answer;
        int x = 0;
        int y = 0;
        for (char c : target)
        {
            int xc = (c - 'a') / 5;
            int yc = (c - 'a') % 5;
            int dx = xc - x;
            int dy = yc - y;
            if (dx < 0)
            {
                answer.append(-dx, 'U');
                if (dy != 0)
                {
                    if (dy > 0)
                    {
                        answer.append(dy, 'R');
                    }
                    else
                    {
                        answer.append(-dy, 'L');
                    }
                }
            }
            else
            {
                if (dy != 0)
                {
                    if (dy > 0)
                    {
                        answer.append(dy, 'R');
                    }
                    else
                    {
                        answer.append(-dy, 'L');
                    }
                }
                if (dx != 0)
                {
                    answer.append(dx, 'D');
                }
            }
            answer.push_back('!');
            x = xc;
            y = yc;
        }
        return answer;
    }
};